package com.ey12.service;

import java.util.ArrayList;
import java.util.List;
import com.ey12.db.dao.GmMemberLevelDAO;
import com.ey12.db.domain.GmMemberLevel;
import com.ey12.utils.DateUtil;

public class GmMemberLevelService {
	private GmMemberLevelDAO gmMemberLevelDAO;

	public GmMemberLevelDAO getGmMemberLevelDAO() {
		return gmMemberLevelDAO;
	}

	public void setGmMemberLevelDAO(GmMemberLevelDAO gmMemberLevelDAO) {
		this.gmMemberLevelDAO = gmMemberLevelDAO;
	}
	public GmMemberLevel getWebGet(int userlevel){
		List list = gmMemberLevelDAO.findWebGetByUserLever(userlevel);
		if(list.size()>0){
			System.out.println(list.size());
			GmMemberLevel gmlevel = (GmMemberLevel)list.get(0);
			System.out.println(gmlevel.getWebGet()+"--"+gmlevel.getToNextLever());
			return gmlevel;
		}
		return null;
	}
	public void addMemberLevel(String levelName,Double webGet,int orderNum) {
		GmMemberLevel m = new GmMemberLevel();
		m.setLevelName(levelName);
		m.setWebGet(webGet);
		m.setOrderNum(orderNum);

		gmMemberLevelDAO.saveOrUpdate(m);
	}
	public List getMemverLevelData(){
		List list = gmMemberLevelDAO.findMemverLevelData();
		System.out.println(list.size());
		return list;
	}
	public void addMemberLevel(GmMemberLevel gmlevel) {
		gmlevel.setId(null);
		gmMemberLevelDAO.saveOrUpdate(gmlevel);
	}
	public void updateMemberLevel(GmMemberLevel gmlevel) {
		gmMemberLevelDAO.saveOrUpdate(gmlevel);
	}
	public void delMemberLevel(GmMemberLevel gmlevel) {
		if(gmlevel!=null){
			gmMemberLevelDAO.delete(gmlevel);
		}
		
}
//public Double getSalerWebGet(int userlevel){
//			List list = gmMemberLevelDAO.findWebGetBySalerLever(userlevel);
//			if(list.size()>0){
//				System.out.println(list.size());
//				Double webGet = (Double)list.get(0);
//				System.out.println(webGet);
//				return webGet;
//			}
//			return 0.0;
//		}
}